﻿using System.Xml;
using UIShell.OSGi;
using Pasys.PresentationCore;
using Pasys.PresentationCore.Utility;


using GeneratorLib.DB;

namespace DBExplorer.Builder
{
    class DBProviderBuilder : BuilderBase<IDBProvider>
    {
        private const string ATTR_TYPE = "type";

        public override void Build(XmlNode xmlNode, IBundle owner)
        {
            string dbProvider = XmlUtility.ReadAttribute(xmlNode, ATTR_TYPE);
            if (string.IsNullOrEmpty(dbProvider))
                return;
            var result = System.Activator.CreateInstance(owner.LoadClass(dbProvider)) as IDBProvider;
            if (result != null)
            {
                AddItem(result);
            }
        }
    }
}
